package com.openx.boot.core.model;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import lombok.Data;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

/**
 * 分页查询结果
 *
 * @author yadu
 */
@Data
@ApiModel(value = "分页查询结果")
@JsonIgnoreProperties(ignoreUnknown = true)
public class PageResult<T> implements Serializable {

    /**
     * 查询数据列表
     */
    private List<T> records = Collections.emptyList();

    /**
     * 总数
     */
    private long total = 0;

    public PageResult() {
    }

    public PageResult(Page<T> page) {
        this.records = page.getRecords();
        this.total = page.getTotal();
    }
}
